<extend name="Public/baseConf" />
<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-8">
	        <h2>{$info['id']?'编辑':'新增'} [{:get_model_by_id($info['model_id'])}] 属性</h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li><a href="{:U('index','model_id='.$info['model_id'])}">属性列表</a></li>
	            <li class="active">
	                <strong>{$info['id']?'编辑':'新增'}属性</strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-4">
            <div class="title-action">
 				<button class="btn btn-primary ajax-post no-refresh" type="submit" target-form="form-horizontal"><i class="fa fa-check"></i>保存</button>
	            <a class="btn btn-warning" type="submit" href="{:U('index','model_id='.$info['model_id'])}"><i class="fa fa-reply"></i>返回</a>
            </div>
        </div>
	</div>  
</block>

<block name="body">
<div class="row">
    <div class="col-lg-12">
		<div class="tabs-container">
		<!-- 表单 -->
		<form id="form" action="{:U('update')}" method="post" class="form-horizontal doc-modal-form">
			<ul class="nav nav-tabs">
				<li class="active"><a data-toggle="tab" href="#tab1"><i class="green fa fa-home bigger-120"></i>基 础</a></li>
				<li><a data-toggle="tab" href="#tab2"><i class="green fa fa-home bigger-120"></i>高 级</a></li>
			</ul>
			<div class="tab-content">
					<!-- 基础 -->
					<div id="tab1" class="tab-pane active">
						<div class="panel-body">
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">字段名<span class="check-tips">（请输入字段名 英文字母开头，长度不超过30）</span></label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="name" value="{$info.name}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">字段标题<span class="check-tips">（请输入字段标题，用于表单显示）</span></label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="title" value="{$info.title}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">字段类型<span class="check-tips">（用于表单中的展示方式）</span></label>
								<div class="col-sm-9">
									<select name="type" id="data-type" class="form-control">
										<option value="">----请选择----</option>
										<volist name=":get_attribute_type()" id="type">
										<option value="{$key}" rule="{$type[1]}">{$type[0]}</option>
										</volist>
									</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">字段定义<span class="check-tips">（字段属性的sql表示）</span></label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="field" value="{$info.field}" id="data-field">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">参数<span class="check-tips">（布尔、枚举、多选字段类型的定义数据）</span></label>
								<div class="col-sm-9">
									<textarea name="extra" class="form-control">{$info.extra}</textarea>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">默认值<span class="check-tips">（字段的默认值）</span></label>
								<div class="col-sm-9">
								<input type="text" class="form-control" name="value" value="{$info.value}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">字段备注<span class="check-tips">(用于表单中的提示)</span></label>
								<div class="col-sm-9">
								<input type="text" class="form-control" name="remark" value="{$info.remark}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">是否显示<span class="check-tips">（是否显示在表单中）</span></label>
								<div class="col-sm-9">
									<select name="is_show" class="form-control" >
										<option value="1">始终显示</option>
										<option value="2">新增显示</option>
										<option value="3">编辑显示</option>
										<option value="0">不显示</option>
									</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">是否必填<span class="check-tips">（用于自动验证）</span></label>
								<div class="col-sm-9">
									<select name="is_must" class="form-control" >
										<option value="0">否</option>
										<option value="1">是</option>
									</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
		                </div>
		            </div>
	                <div id="tab2" class="tab-pane">
		                <div class="panel-body">
		                	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">验证方式</label>
								<div class="col-sm-9">
									<select name="validate_type" class="form-control">
										<option value="regex">正则验证</option>
										<option value="function">函数验证</option>
										<option value="unique">唯一验证</option>
										<option value="length">长度验证</option>
		                                <option value="in">验证在范围内</option>
		                                <option value="notin">验证不在范围内</option>
		                                <option value="between">区间验证</option>
		                                <option value="notbetween">不在区间验证</option>
									</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
		                	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">验证规则<span class="check-tips">（根据验证方式定义相关验证规则）</span></label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="validate_rule" value="{$info.validate_rule}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">出错提示</label>
								<div class="col-sm-9">
								<input type="text" class="form-control" name="error_info" value="{$info.error_info}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">验证时间</label>
								<div class="col-sm-9">
										<select name="validate_time" class="form-control">
		                                <option value="3">始 终</option>
										<option value="1">新 增</option>
										<option value="2">编 辑</option>
										</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">自动完成方式</label>
								<div class="col-sm-9">
									<select name="auto_type" class="form-control">
										<option value="function">函数</option>
										<option value="field">字段</option>
										<option value="string">字符串</option>
									</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">自动完成规则<span class="check-tips">（根据完成方式订阅相关规则）</span></label>
								<div class="col-sm-9">
									<input type="text" class="form-control" name="auto_rule" value="{$info.auto_rule}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
	                    	<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">自动完成时间</label>
								<div class="col-sm-9">
									<select name="auto_time" class="form-control">
										<option value="3">始 终</option>
										<option value="1">新 增</option>
										<option value="2">编 辑</option>
									</select>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
						</div>
					</div>
					<input type="hidden" name="id" value="{$info['id']}"/>
					<input type="hidden" name="model_id" value="{$info['model_id']}"/>
			</div>
		</form>
		</div>
	</div>
</div>
</block>
<block name="script">
	<script type="text/javascript" charset="utf-8">
	//导航高亮
	Think.setValue('type', "{$info.type|default=''}");
	Think.setValue('is_show', "{$info.is_show|default=1}");
	Think.setValue('is_must', "{$info.is_must|default=0}");
	Think.setValue('validate_time', "{$info.validate_time|default=3}");
	Think.setValue('auto_time', "{$info.auto_time|default=3}");
	Think.setValue('validate_type', "{$info.validate_type|default='regex'}");
	Think.setValue('auto_type', "{$info.auto_type|default='function'}");
	$(function(){
		showTab();
	})
	<eq name="ACTION_NAME" value="add">
		$(function(){
			$('#data-type').change(function(){
				$('#data-field').val($(this).find('option:selected').attr('rule'));
			});
		})
	</eq>
	</script>
</block>

